fix(mdcode): use project id (not literal "projects") in the aspect-type cache key#124
Open
mftnakrsu wants to merge 1 commit into
Open
Conversation
…t-type cache key
When caching a required aspect type, CatalogSnapshot splits the aspect-type resource name (projects/{project}/locations/{location}/aspectTypes/{type}) on '/' and fetches it with getAspectType(parts[1], parts[3], parts[5]) — correct — but then registers the compact alias key as `${parts[0]}.${parts[3]}.${parts[5]}`, where parts[0] is the literal string 'projects'. So the key becomes e.g. 'projects.global.bigquery-table' instead of '{project}.global.bigquery-table'. That wrong key breaks the dedup check and leaks an invalid value into lookupEntry's aspectTypes query param. Fix: use parts[1] (the project id), matching the established convention in gcp/dataplex.ts::_nameToTypeRef (`${nameParts[1]}.${nameParts[3]}.${nameParts[5]}`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
CatalogSnapshotbuilds the compact aspect-type alias key from the wrong path segment, so the cached key starts with the literal stringprojectsinstead of the actual project id.Why
The aspect-type resource name is
projects/{project}/locations/{location}/aspectTypes/{type}. Aftersplit('/'):parts[0]='projects',parts[1]=project,parts[3]=location,parts[5]=type. The fetch uses the right segments:but the alias key uses
parts[0]:So the key becomes e.g.
projects.global.bigquery-tableinstead of<project>.global.bigquery-table, which breaks the dedup lookup and leaks an invalid value intolookupEntry'saspectTypesquery param.Change
Use
parts[1](the project id), matching the established convention ingcp/dataplex.ts::_nameToTypeRef→${nameParts[1]}.${nameParts[3]}.${nameParts[5]}.Verification
npm run compile✅ andnpm run test✅ (17 pass / 0 fail) intoolbox/mdcode.Note for maintainers
The same one-line bug exists in the parallel
agents/mdcode/src/libts/snapshot.tscopy (three sites: the success + 403-placeholder branches and the reference-aspect loop). I scoped this PR totoolbox/mdcodeonly becauseagents/mdcodecurrently has pre-existing compile (TS6133unused-var) and test failures onmainunrelated to this change (verified: pristinemainshows the same 8 pass / 19 fail), so a green run isn't achievable there yet. Happy to extend this PR to theagents/mdcodecopy if you'd prefer.🤖 Generated with Claude Code